package objectsDiagram;

import java.awt.Color;
import java.awt.Point;
import java.util.Vector;

public class State{
	private String id;
	private String name;
	private Vector<Flow> flowsIn;
	private Vector<Flow> flowsOut;
	private Point portSplit;
	private Point portJoin;
	
	//atrrs for Canvas
	private int coordX;
	private int coordY;
	private int width;
	private int height;
	private Point portNorth;
	private Point portSouth;
	private Point portEast;
	private Point portWest;
	
	//atrrs for state's lavel
	private int coordLabX;
	private int coordLabY;
	private int widthLab;
	private int heightLab;

	private DecoratorTask decorJoin;
	private DecoratorTask decorSplit;
	
	private boolean isSelected;
	private Color color;
	private boolean inTrace = false;
	
	public State(){
		flowsIn = new Vector<Flow>();
		flowsOut = new Vector<Flow>();
		isSelected = false;
		color = Color.BLACK;
	}

	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public int getCoordX() {
		return coordX;
	}


	public void setCoordX(int coordX) {
		this.coordX = coordX;
	}


	public int getCoordY() {
		return coordY;
	}


	public void setCoordY(int coordY) {
		this.coordY = coordY;
	}


	public int getWidth() {
		return width;
	}


	public void setWidth(int width) {
		this.width = width;
	}


	public int getHeight() {
		return height;
	}


	public void setHeight(int height) {
		this.height = height;
	}

	public Point getPortNorth() {
		return portNorth;
	}

	public void setPortNorth(Point portNorth) {
		this.portNorth = portNorth;
	}

	public Point getPortSouth() {
		return portSouth;
	}

	public void setPortSouth(Point portSouth) {
		this.portSouth = portSouth;
	}

	public Point getPortEast() {
		return portEast;
	}

	public void setPortEast(Point portEast) {
		this.portEast = portEast;
	}

	public Point getPortWest() {
		return portWest;
	}

	public void setPortWest(Point portWest) {
		this.portWest = portWest;
	}

	public int getCoordLabX() {
		return coordLabX;
	}


	public void setCoordLabX(int coordLabX) {
		this.coordLabX = coordLabX;
	}


	public int getCoordLabY() {
		return coordLabY;
	}


	public void setCoordLabY(int coordLabY) {
		this.coordLabY = coordLabY;
	}


	public int getWidthLab() {
		return widthLab;
	}


	public void setWidthLab(int widthLab) {
		this.widthLab = widthLab;
	}


	public int getHeightLab() {
		return heightLab;
	}


	public void setHeightLab(int heightLab) {
		this.heightLab = heightLab;
	}

	public Vector<Flow> getFlowsIn() {
		return flowsIn;
	}

	public void addFlowsIn(Flow flowsIn) {
		this.flowsIn.add(flowsIn);
	}
	
	public void setFlowsIn(Vector<Flow> newFlowsIn){
		this.flowsIn = newFlowsIn;
	}

	public Vector<Flow> getFlowsOut() {
		return flowsOut;
	}

	public void addFlowsOut(Flow flowsOut) {
		this.flowsOut.add(flowsOut);
	}
	
	public void setFlowsOut(Vector<Flow> newFlowsOut){
		this.flowsOut = newFlowsOut;
	}

	public Point getPortSplit() {
		return portSplit;
	}

	public void setPortSplit(Point newPortSplit) {
		this.portSplit = newPortSplit;
	}

	public Point getPortJoin() {
		return portJoin;
	}

	public void setPortJoin(Point newPortJoin) {
		this.portJoin = newPortJoin;
	}

	
	public boolean isSelected() {
		return isSelected;
	}

	
	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}
	
	//methods for decorate task
	public DecoratorTask getDecorJoin() {
		return decorJoin;
	}

	public void setDecorJoin(DecoratorTask decorJoin) {
		this.decorJoin = decorJoin;
	}

	public DecoratorTask getDecorSplit() {
		return decorSplit;
	}

	public void setDecorSplit(DecoratorTask decorSplit) {
		this.decorSplit = decorSplit;
	}

	public boolean isInTrace() {
		return inTrace;
	}

	public void setInTrace(boolean inTrace) {
		this.inTrace = inTrace;
	}

	@Override
	public String toString() {
		return "State [id=" + id + ", name=" + name + ", flowsIn=" + flowsIn
				+ ", flowsOut=" + flowsOut + ", portSplit=" + portSplit
				+ ", portJoin=" + portJoin + ", coordX=" + coordX + ", coordY="
				+ coordY + ", width=" + width + ", height=" + height
				+ ", coordLabX=" + coordLabX + ", coordLabY=" + coordLabY
				+ ", widthLab=" + widthLab + ", heightLab=" + heightLab
				+ ", decorJoin=" + decorJoin + ", decorSplit=" + decorSplit
				+ ", isSelected=" + isSelected + ", color=" + color + "]";
	}
	
	public State cloneState(){
		State newState = new State();
		newState.setId(id);
		newState.setName(name);
		Vector<Flow> newFlowsIn = new Vector<Flow>();
		Vector<Flow> newFlowsOut = new Vector<Flow>();
		for(int i=0;i<this.getFlowsIn().size();i++){
			newFlowsIn.add(this.getFlowsIn().get(i).clone());
		}
		for(int i=0;i<this.getFlowsOut().size();i++){
			newFlowsOut.add(this.getFlowsOut().get(i).clone());
		}
		newState.setFlowsIn(newFlowsIn);
		newState.setFlowsOut(newFlowsOut);
		
		newState.setPortJoin(new Point(portJoin.x,portJoin.y));
		newState.setPortSplit(new Point(portSplit.x,portSplit.y));
		newState.setCoordX(new Integer(coordX));
		newState.setCoordY(new Integer(coordY));
		newState.setWidth(new Integer(width));
		newState.setHeight(new Integer(height));
		newState.setCoordLabX(new Integer(coordLabX));
		newState.setCoordLabY(new Integer(coordLabY));
		newState.setWidthLab(new Integer(widthLab));
		newState.setHeightLab(new Integer(heightLab));
		newState.setDecorJoin(decorJoin.clone());
		newState.setDecorSplit(decorSplit.clone());
		newState.setSelected(isSelected);
		newState.setColor(color);
		return newState;
	}
	
	
}
